$('.topRight>ul>li').hover(function () {
    $(this).children().first().css('ccolor','#f10180')
},function () {
    $(this).children().first().css('color','#000')
})
$('.dw').hover(function () {
    $(this).children().lat().stop().slideDown(300,'swing')
}, function () {
    $(this).children().last().stop().slideUp(100,'swing')
})
$('.dw>ol>li').hover(function () {
    $(this).css({
        backgroundColor: '#f10180',
        color:'#fff',
    })
}, function () {
    $(this).css({
        'background-color': '#fff',
        color: '#000'
    })
})
$('#ss').on('input',function(){
    $.ajax({
        url: 'https://category.vip.com/ajax/getSuggest.php',
        dataType: 'jsonp',
        data: {
            callback: 'searchSuggestions',
            keyword: $('#ss').val(),
        },
    })
})
function searchSuggestions(res) {
    console.log(res)
    var list = res.data
    var str = ''
    list.forEach(item => {
         str += `
             <li class="searchK-footer">${item.word}</li>
         `
    });
    document.querySelector('.searchK-foot').innerHTML = str
}
$('#ss').click(function(){
    $(this).parent().children().last().stop().show()
})
$('.searchK').hover(function(){

},function(){
    $(this).children().last().hide()
})
$('.seachK-footer').hover(function () {
    $(this).css('color', '#f10180')
},function () {
    $(this).css('color', '#333')
})
$('.link-anim>dd').hover(function () {
    $(this).children().animate({
        'padding-left': '3px',
    },200,'swing')
    $(this).children().css('color','#F10180')
}, function () {
    $(this).children().animate({
        'padding-left': '0px',
    },100,'swing')
    $(this).children().css('color','#4d4d4d')
})
$('.font-infor-link>a').hover(function () {
  $(this).css('color','#ccc')   
},function () {
    $(this).css('color','#fff')
})
$('.foot-infor-tet a').hover(function () {
    $(this).css('color','#f10180')
},function () {
    $(this).css('color', '#333')
})
$('.listX1').hover(function () {
    $(this).children().last().stop().slideDown(200,'swing')
},function () {
    $(this).children().last().stop().slideUp(200,'swing')
})
$('.listX1>ol>li').hover(function () {
   $(this).css('color','#f10180') 
},function () {
    $(this).css('color','#333')
})
$('.logoThree').hover(function () {
    $(this).children().last().stop().slideUp(200,'swing')
},function () {
    $(this).children().last().stop().slideUp(200,'swing')
})
$('.aw').hover(function () {
    $(this).children().last().stop().slideDown(200,'swing')
},function () {
    $(this).children().last().stop().slideUp(200,'swing')
})
$('.top-login').hover(function () {
    $(this).children().last().stop().slideDown(200,'swing')
},function () {
    $(this).children().last().stop().slideUp(200,'swing')
})
$('.top-login>ol>li').hover(function () {
    $(this).css('color','#f10180')
},function () {
    $(this).css('color','#333')
})
$('.top-sign').hover(function () {
    $(this).children().last().stop().slideDown(200,'swing')
},function () {
    $(this).children().last().stop().slideUp(200,'swing')
})
var userid = localStorage.getItem('id')
var token = localStorage.getItem('token')
if(!userid || !token){
    layer.msg('请先登录',{
        icon:2,
        time:1500
    },()=>{
        localStorage.setItem('url', location.href)
        location.href = 'login.html'
    })
}
var arr =localStorage.getItem('data')
arr = JSON.parse(arr)
console.log(arr)
$.ajax({
    url:'https://o2api.jd.com/data?body=%7B%22query%22%3A%22query%20getCommodities(%24ids%3A%20String)%7Bcommodities(ids%3A%20%24ids)%7BgroupId%2C%20groupName%2C%20productList%7BskuId%20name%20image%20title%20productImage%20currentPrice%20jdPrice%20pPrice%20groupId%7D%7D%7D%22%2C%22operationName%22%3A%22getCommodities%22%2C%22variables%22%3A%7B%22ids%22%3A%22%5B09911690%5D%22%7D%2C%22config%22%3A%7B%22cache%22%3Afalse%2C%22trim%22%3Atrue%2C%22map%22%3A%7B%22keyBy%22%3A%22groupId%22%2C%22valueField%22%3A%22productList%22%7D%7D%7D&callback=o242f1a30297a868c0240a822f7c04a46f&_=1635833562536',
    dataType: 'jsonp',
})
function o242f1a30297a868c0240a822f7c04a46f(res){
    var list = res.data['09911690']
    console.log(list)
    list = list.filter(item=>{
        for(var i = 0;i<arr.length;i++){
            if(arr[i].id === item.skuId){
                return true
            }
        }
    })
    var str = '';
    list.forEach(item=>{
        var number = arr.find(v=>v.id === item.skuId).number
        str +=`
            <tr class="check">
                <td>
                    <input type="checkbox">
                </td>
                <td>
                    <img src="${item.image}" style="width:74px;height:74px;" />
                </td>
                <td style="width:400px;">${item.name}</td>
                <td>￥${item.pPrice}</td>
                <td class="number">
                    <button>-</button>
                    <input type="number" value="${number}"></input>
                    <button>+</button>
                </td>
                <td class="del">删除商品</td>
            </tr>
        `
    })
    $('table tbody').html(str)
}
$('tbody').on('click','.del',function(){
    $(this).parent().remove()
})